<!-- 客户管理 - 综合表单页面 -->
<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />

    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e">
    </ex_super_table_page>


    <ex_super_dialog_form ref="auditDialog" v-bind="auditDialog" @afterSubmitSuccess="reload()">
    </ex_super_dialog_form>

    <ex_super_dialog_form ref="levelDialog" v-bind="levelDialog" @afterSubmitSuccess="reload()">
    </ex_super_dialog_form>

    <!--   用户代表分配  -->
    <ex_super_dialog_form ref="assignDialog" v-bind="assignDialog" @afterSubmitSuccess="reload()">
    </ex_super_dialog_form>
    <ex_super_dialog_form ref="returnGoodDialog" v-bind="returnGoodDialog" @afterSubmitSuccess="reload()">
    </ex_super_dialog_form>

    <!--   分配仓库  -->
    <el-dialog title="分配仓库" :visible.sync="assignWarehouseDialogFormVisible" width="880px">
      <el-form ref="formEl" :model="assignWarehouseFormValue" :rules="rules" label-width="120px"
        class="common-form-panel-div" style="padding: 0px;">
        <el-row>
          <el-col>
            <el-form-item label="客户编号">
              <label>{{ assignWarehouseFormValue.customerNoLabel }}</label>
              <!--              <el-tag v-for="(item , index ) in assignWarehouseFormValue.customerNoList"> {{item}} </el-tag>-->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item label="分配仓库" label-position="top">
            <el-transfer filterable :titles="['待分配仓库', '已分配仓库']" :button-texts="['取消', '分配']" :props="{
              key: 'id',
              value: 'name',
              label: 'name'
            }" :filter-method="(query, item) => item.name.indexOf(query) > -1" filter-placeholder="请输入仓库名称"
              v-model="assignWarehouseFormValue.value" :data="allWarehouseList">
            </el-transfer>
          </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="assignWarehouseDialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="companyAssignWarehouse">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 商品差异设置    -->
    <mms_sku_diff_setting ref="mms_sku_diff_setting"></mms_sku_diff_setting>
  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
import emitOnFunction from '@/mixin/emit-on-function';
import mms_sku_diff_setting from "@/component/mms/mms_sku_diff_setting.vue";
import page_table_model_manage from '@/mixin/page_table_model_manage';
import country_select from '@/component/tms/country_select'
import router_params from '@/mixin/router_params';

import { mapState } from "vuex";

let emitKey = 'ums>customer_info_manage'
export default {
  title: 'title_customer_info_manage',
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage, router_params,],
  components: { mms_sku_diff_setting, country_select },
  data() {


    return {
      selection: [],
      warehouseList: [],
      isConfirm_routeParamsChange: false,

      // 分配仓库标记
      assignWarehouseDialogFormVisible: false,
      assignWarehouseFormValue: {
        companyIdList: [],
        value: [],
      },
      assignDialog: {
        customClass: 'dialog_small',
        submitUrl: '/ums-api/customer/CustomerCompanyRpc/assignUser4Company.json',
        submitDataHandle: (data) => {
          const { list, ...other } = data
          return {
            companyIdList: list.map(it => it.id),
            ...other,
          }
        },
        form: {
          itemClass: "form_item_default",
          inputClass: "form_input_default",
          // formClass: "form_default_col2 flex_row_wrap",
          default: {},
          model: [
            {
              key: "saleUserSecurityId", label: "label_sales_rep", type: 'common_user_select',

              attrs: { clearable: true },
              keyExtra: { userName: 'saleUserName', userId: 'saleUserSecurityId' },
            },
            {
              key: "cserUserSecurityId", label: "label_customer_service_rep", type: 'common_user_select',
              attrs: { clearable: true },

              keyExtra: { userName: 'cserUserName', userId: 'cserUserSecurityId' },
            },
          ],

        }
      },
      levelDialog: {
        customClass: 'dialog_small',
        submitUrl: '/ums-api/customer/CustomerCompanyRpc/settingCompanyLevel.json',
        submitDataHandle: (data) => {
          return {
            idList: data.list.map(it => it.id),
            companyLevel: data.companyLevel,
          }
        },
        form: {
          inputClass: "bold",
          // itemClass: "form_item_default",
          // inputClass: "form_input_default",
          // formClass: "form_default_col2 flex_row_wrap",
          default: {},
          model: [
            {
              key: "list", label: "label_customer_name", formType: 'text',
              formatter: (r, c, v, i) => v ? v.map(it => it.companyName).join(',') : ""
            },
            {
              key: "companyLevel", label: "label_company_level", type: "select",
              enum: 'UmsCompanyLevelEnum'
            },
          ],
          rules: {
            companyLevel:
              { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
          },
        }
      },


      auditDialog: {
        id: "customerAuditDialog",
        customClass: 'dialog_default',
        submitUrl: '/ums-api/customer/CustomerCompanyRpc/auditCustomer.json',
        submitType: 'form',
        submitDataHandle: (data) => {
          return {
            customerId: data.id,
            customerCode: data.companyCode,
            customerName: data.companyName,
            auditResult: data.auditResult,
            failMessage: data.failMessage,
          }
        },
        detailUrl: "/ums-api/customer/CustomerCompanyRpc/detail.json",
        form: {

          inputClass: "bold",
          // itemClass: "form_item_default",
          // inputClass: "form_input_default",
          // formClass: "form_default_col2 flex_row_wrap",
          default: {},
          model: [
            { header: "label_base_info", },
            {
              key: "customerType", label: "label_srm_insurance_insue_log_customer_type", formType: 'text',
              formatter: (r, c, v, i) => this.$enumShow(v, 'UmsCustomerType')
            },
            {
              if: (data) => data.customerType == 'PERSON',
              grid: [
                [
                  {
                    span: 12,
                    col: {
                      key: "contactName", label: "label_user_name", formType: 'text',
                      render: (h, { data, item }) => this.$renderText(h, data[item.key])
                    },
                  },
                  {
                    span: 12,
                    col: {
                      key: "companyCode", label: "label_srm_api_request_customer_code", 
                      render: (h, { data, item }) => {
                        return h('div', { class: 'form_input_default flex_row_center' }, [
                          h('el-input', {
                            props: {
                              value: data.companyCode,
                              disabled: !!data.disabledCompanyCode,
                            },
                            on: {
                              input: e => this.$set(data, item.key, e.trim())
                            },
                          }),
                          h('el-button', {
                            class: "mg_l1",
                            props: { type: 'primary', },
                            on: {
                              click: () => {
                                this.generateCompanyCode((v) => {
                                  this.$set(data, item.key, v)
                                  if (this.$loginUser.ifElse新邮 || this.$loginUser.ifElse澳越) {
                                    this.$set(data, "disabledCompanyCode", true)
                                  }
                                })
                              }
                            }
                          }, this.$t('label_generate'))
                        ])
                      },
                      rules: (data) => {
                        if (data.auditResult == 'SUCCESS') {
                          return { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' }
                        }
                        return null
                      }

                    },
                  },
                ],
                [
                  {
                    span: 12,
                    col: {
                      key: "contactPhone", label: "label_phone_number", formType: 'text',
                      render: (h, { data, item }) => this.$renderText(h, data[item.key])
                    },
                  },
                  {
                    span: 12,
                    col: {
                      key: "contactIdType", label: "label_idcard_number", formType: 'text',
                      formatter: (r, c, v, i) => this.$enumShow(v, 'IdTypeEnum') + (r.contactIdNo ? (' - ' + r.contactIdNo) : "")
                    },
                  },
                ],
                [
                  {
                    span: 24,
                    col: {
                      key: "legalIdNoFiles", label: "label_idcard_photo",
                      render: (h, { data, item }) => {
                        if (!data.legalIdNoFiles) {
                          return this.$renderText(h, data.legalIdNoFiles)
                        }
                        const piclist = data.legalIdNoFiles
                        return h('div', {}, piclist.map(it => {
                          return h('ex_image_view', {
                            style: { width: '100px', height: '100px' },
                            class: 'border_normal mg_1',
                            props: { lazy: true, fit: 'fill', src: it, 'preview-src-list': piclist }
                          })
                        }))
                      }

                    },
                  },
                ],
              ],
            },

            {
              if: (data) => data.customerType == 'COMPANY',
              grid: [
                [
                  {
                    span: 12,
                    col: {
                      key: "companyName", label: "label_company_name", formType: 'text',
                      render: (h, { data, item }) => this.$renderText(h, data[item.key])
                    },
                  },
                  {
                    span: 12,
                    col: {
                      key: "companyCode", label: "label_company_code",
                      render: (h, { data, item }) => {
                        return h('div', { class: 'form_input_default flex_row_center' }, [
                          h('el-input', {
                            props: {
                              value: data.companyCode,
                              disabled: !!data.disabledCompanyCode,
                            },
                            on: {
                              input: e => this.$set(data, item.key, e.trim())
                            },
                          }),
                          h('el-button', {
                            class: "mg_l1",
                            props: { type: 'primary', },
                            on: {
                              click: () => {
                                this.generateCompanyCode((v) => {
                                  this.$set(data, item.key, v)
                                  if (this.$loginUser.ifElse新邮 || this.$loginUser.ifElse澳越) {
                                    this.$set(data, "disabledCompanyCode", true)
                                  }
                                })
                              }
                            }
                          }, this.$t('label_generate'))
                        ])
                      },
                      rules: (data) => {
                        if (data.auditResult == 'SUCCESS') {
                          return { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' }
                        }
                        return null
                      }
                    },
                  },
                ],
                [
                  {
                    span: 24,
                    col: {
                      key: "companyCreditCode", label: "label_unified_credit_code", if: (data) => data.addressType !== "OVERSEAS", formType: 'text',
                      render: (h, { data, item }) => this.$renderText(h, data[item.key])
                    },
                  },
                ],
                [
                  {
                    span: 24,
                    col: {
                      key: "companyCreditCode", label: "label_business_registration_number", if: (data) => data.addressType === "OVERSEAS", formType: 'text',
                      render: (h, { data, item }) => this.$renderText(h, data[item.key])
                    },
                  },
                ],
                [
                  {
                    span: 12,
                    col: {
                      key: "addressType", label: "label_register_address_type",
                      render: (h, { data, item }) => this.$renderText(h, this.$enumShow(data[item.key], "UserCompanyAddressType"))
                    },
                  },
                  {
                    span: 12,
                    col: {
                      key: "registAddress", label: "label_register_address", formType: 'text',
                      render: (h, { data, item }) => {
                        const text = data[item.key] && data[item.key].length == 3 ? _.takeRight(data[item.key], 2).filter(it => it).join('/') : ""
                        return this.$renderText(h, text)
                      }
                    },
                  },
                ],
                [
                  {
                    span: 24,
                    col: {
                      key: "legalIdNoFiles", label: "label_Attachment_Corporate_Identity_Card",
                      render: (h, { data, item }) => {

                        if (!data[item.key]) {
                          return this.$renderText(h, data[item.key])
                        }
                        const piclist = data.legalIdNoFiles
                        return h('div', {}, piclist.map(it => {
                          return h('ex_image_view', {
                            style: { width: '100px', height: '100px' },
                            class: 'border_normal mg_1',
                            props: { lazy: true, fit: 'fill', src: it, 'preview-src-list': piclist }
                          })
                        }))
                      }

                    },
                  },
                ],

                [
                  {
                    span: 24,
                    col: {
                      key: "licenseFile", label: "label_Business_License_Attachment",
                      render: (h, { data, item }) => {
                        if (!data[item.key]) {
                          return this.$renderText(h, data[item.key])
                        }
                        const piclist = [data.licenseFile]
                        return h('div', {}, piclist.map(it => {
                          return h('ex_image_view', {
                            style: { width: '100px', height: '100px' },
                            class: 'border_normal mg_1',
                            props: { lazy: true, fit: 'fill', src: it, 'preview-src-list': piclist }
                          })
                        }))
                      }
                    },
                  },
                ],
                [
                  {
                    span: 24,
                    col: {
                      if: (data) => data.addressType == "OVERSEAS",
                      key: "companyRegistNo", label: "label_company_registration_card_number",
                      render: (h, { data, item }) => this.$renderText(h, data[item.key])
                    },
                  },
                ],
                [
                  {
                    span: 24,
                    col: {
                      if: (data) => data.addressType == "OVERSEAS",
                      key: "companyRegistFile", label: "label_company_registration_card",
                      render: (h, { data }) => {
                        if (_.isEmpty(data.companyRegistFile)) {
                          return this.$renderText(h, data.companyRegistFile)
                        }
                        const piclist = [data.companyRegistFile]
                        return h('div', {}, piclist.map(it => {
                          return h('ex_image_view', {
                            style: { width: '100px', height: '100px' },
                            class: 'border_normal mg_1',
                            props: { lazy: true, fit: 'fill', src: it, 'preview-src-list': piclist }
                          })
                        }))
                      }
                    },
                  },
                ],
              ],
            },
            { header: "label_contact_info", if: (data) => data.customerType == 'COMPANY', },
            {
              if: (data) => data.customerType == 'COMPANY',
              grid: [
                [
                  {
                    span: 12,
                    col: {
                      key: "contactName", label: "label_contact_name", formType: 'text',
                      render: (h, { data, item }) => this.$renderText(h, data[item.key])
                    },
                  },
                  {
                    span: 12,
                    col: {
                      key: "contactPhone", label: "label_contact_phone", formType: 'text',
                      render: (h, { data, item }) => this.$renderText(h, data[item.key])
                    },
                  },
                ],
              ],
            },
            { header: "label_fms_account_log_examine_result", },
            {
              grid: [
                [
                  {
                    span: 12,
                    col: {
                      key: "auditResult", label: "label_fms_account_log_examine_result",
                      render: (h, { data }) => (
                        <el-radio-group value={data.auditResult} onInput={e => this.$set(data, 'auditResult', e)}>
                          <el-radio label="SUCCESS">{this.$tt('enum_examine_pass')}</el-radio>
                          <el-radio label="FAIL">{this.$tt('enum_examine_reject')}</el-radio>
                        </el-radio-group>
                      )

                    },
                  },
                  {
                    span: 12,
                    col: {
                      if: (data) => data.auditResult == 'FAIL',
                      key: "failMessage", label: "label_fms_account_log_examine_fail_reason", inputClass: "form_input_default",
                    },
                  },
                ],
              ],
            },
          ],
          rules: {
            auditResult:
              { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            failMessage:
              { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
          },
        }
      },
      returnGoodDialog: {
        customClass: 'dialog_small',
        submitUrl: '/ums-api/customer/CustomerCompanyRpc/batchUpdateCustomerBusinessData.json',
        submitDataHandle: (data) => {
          return {
            companyIdList: data.list.map(it => it.id),
            returnProcessMethodList: data.returnProcessMethodList,
          }
        },
        form: {
          inputClass: "bold",
          // itemClass: "form_item_default",
          // inputClass: "form_input_default",
          // formClass: "form_default_col2 flex_row_wrap",
          default: {},
          model: [
            {
              key: "list", label: "label_customer_name", formType: 'text',
              formatter: (r, c, v, i) => v ? v.map(it => it.companyName).join(',') : ""
            },
            {
              key: "returnProcessMethodList", label: "label_sku_return_method", type: "select", multiple: true, clearable: true,
              enum: 'SkuReturnMethodEnum'
            },
          ],
          rules: {
          },
        }
      },

      rules: {
        companyName: [
          { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
          { min: 3, max: 32, message: this.$tt('tip_length_in_min_max', { min: 3, max: 32 }), trigger: 'blur' }
        ],
        companyCode: [
          { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
          { min: 3, max: 16, message: this.$tt('tip_length_in_min_max', { min: 3, max: 16 }), trigger: 'blur' }
        ]
      },


      option: {
        autoLoad: false,
        search: {
          model: [
            {
              label: "label_customer", key: "customerIdsQueryStr", type: 'common_customer_choose', attrs: { multiple: true, }, inputStyle: { 'width': '400px' },
            },
            {
              label: "label_company_level", key: "companyLevel", type: 'select', enum: 'UmsCompanyLevelEnum',
            },
            {
              label: "label_country", key: "country", type: country_select, attrs: {
                optionValue: 'countryName',
                url: '/oms-api/base/OmsCountryRpc/selectAllLabel.json',
              }
            },
          ],
        },
        action: [
          {
            if: () => this.queryStatus == '',
            label: 'label_add_customer', attrs: { icon: "el-icon-plus" },
            auth: 'ums_customer_edit',
            click: () => {
              this.$router.push({
                path: '/page/ums/customer/customer_operate', query: { emitKey }
              });
            }
          },
          {
            if: () => this.queryStatus == '',
            label: 'label_assign_rep', attrs: {},
            auth: 'ums_customer_edit',

            click: () => {
              if (_.isEmpty(this.selection)) {
                this.$message.error(this.$tt('tip_please_select_first_customer'))
                return
              }
              this.$refs.assignDialog.showNew({
                title: this.$tt("label_assign_rep"),
                data: {
                  list: this.selection,
                },
                onlySetData: true,
              })
            }
          },
          {
            if: () => this.queryStatus == '',
            label: '分配仓库', attrs: {},
            auth: 'ums_customer_edit',

            click: () => {
              if (_.isEmpty(this.selection)) {
                this.$message.error(this.$tt('tip_please_select_first_customer'))
                return
              }
              this.assignWarehousePrefix()
            }
          },
          {
            if: () => this.queryStatus == '',
            label: 'label_company_level',
            auth: 'ums_customer_edit',

            click: (row) => {
              if (_.isEmpty(this.selection)) {
                this.$message.error(this.$tt('tip_please_select_first_customer'))
                return
              }
              this.$refs.levelDialog.showNew({
                title: this.$tt("label_company_level"),
                data: {
                  list: this.selection,
                },
                onlySetData: true,
              })
            }

          },
          {
            if: () => this.queryStatus == '',
            label: 'label_sku_diff_settings', attrs: {},
            auth: 'ums_customer_sku_diff_settings',
            click: () => {
              if (_.isEmpty(this.selection)) {
                this.$message.error(this.$tt('tip_please_select_first_customer'))
                return
              }
              this.customerSkuDiffSettingDialog(this.selection)

            }
          },
        ],

        table: {
          url: "/ums-api/customer/CustomerCompanyRpc/select.json?status=" + this.queryStatus,
          model: this.init_table_model(),
        }
      }

    };
  },

  computed: {
    ...mapState({ allWarehouseList: state => state.allWarehouseList }),
  },
  props: {
    queryStatus: {
      type: String,
      default: ''
    }
  },
  watch: {
    'assignWarehouseDialogFormVisible'(val, old) {
      if (!val) {
        // 重置表单
        this.assignWarehouseFormValue = {
          companyIdList: [],
          value: [],
        }
      }
    },

  },
  methods: {
    init_data_default(into_params) {
      const search = Object.assign({}, this.$refs.SuperTablePage.getSearchFormData(), into_params)
      this.$refs.SuperTablePage.setSearchData(search)
      this.$refs.SuperTablePage.loadDataForSearch()
    },
    option_table_model() {
      return [
        { type: 'selection', clickToggle: true },
        {
          key: 'companyName', label: 'label_company_name', align: 'left', width: 160, attrs: {
            formatter: (r, c, v, i) =>
              this.$formatNameCode(v, r.isTest == 'Y' ? '测试企业' : r.customerType == 'PERSON' ? '个人' : '')


          }
        },
        {
          key: 'companyCode', label: 'label_company_code', align: 'left', width: 160, attrs: {}
        },
        { key: 'companyCreditCode', label: 'label_unified_credit_code', align: 'left', width: 200 },
        {
          key: 'registAddress', label: 'label_register_address', align: 'left', width: 280,
          render: (h, { row, column }) => {
            const text = row[column.property] && row[column.property].length == 3 ? _.takeRight(row[column.property], 2).filter(it => it).join('/') : ""
            return this.$renderText(h, text)
          }

        },
        {
          key: 'mailAddress', label: 'label_mail_address', align: 'left', width: 280, attrs: {
            formatter: (r, c, v, i) => {
              if (v && v.length == 3 && v[1] && v[1] != '') {
                return v[1].replace(/\//g, '') + v[2]
              }
              return ''
            }
          }
        },
        {
          key: 'companyLevel',
          label: 'label_company_level',
          'width': 120,
          formatter: (r, c, v, i) => this.$enumShow(v, "UmsCompanyLevelEnum")
        },
        { key: 'companyTel', label: 'label_company_landline', align: 'left', 'width': 130, },
        { key: 'email', label: 'label_mailbox', align: 'left', 'width': 130, },
        {
          key: 'contactName', label: 'label_contact', align: 'left', attrs: {
            formatter: (r, c, v, i) => {
              let tmp = ''
              if (r.contactName) {
                tmp += r.contactName
              }
              if (r.contactPhone) {
                tmp += '  ' + r.contactPhone
              }
              return tmp
            }
          }
        },

        {
          key: 'gmtCreate',
          label: 'label_create_time',
          'width': 140,
          attrs: { formatter: (r, c, v, i) => this.$dateFormat(v) },
        },

        {
          key: 'status',
          label: 'label_status',
          'width': 120,
          formatter: (r, c, v, i) => this.$enumShow(v, "UserStatusEnum")
        },

        {
          type: 'operate', width: 220, fixed: 'right', operate: [
            {
              if: row => row.registSource == 'BY_MANAGER',
              label: 'label_edit', auth: 'ums_customer_edit', click: (row) => {
                this.$router.push({
                  path: '/page/ums/customer/customer_operate', query: { id: row.id, emitKey, edit: true, }
                });
              }
            },
            {
              if: row => row.status == 'NEED_AUDIT',
              label: 'label_fms_account_apply_audit',
              auth: 'ums_customer_audit',
              click: (row) => {
                this.$refs.auditDialog.showNew({
                  title: this.$tt('label_user_registration_information_review'),
                  data: Object.assign({ "auditResult": "SUCCESS" },),
                  params: { id: row.id },
                  // onlySetData: true,
                })
              }
            },
            {
              label: 'label_view_detail', click: (row) => {
                this.$router.push({
                  path: '/page/ums/customer/customer_detail', query: { id: row.id, emitKey, }
                });
              }
            },
            {
              label: 'label_sku_diff_settings', if: () => this.queryStatus == '',
              auth: 'ums_customer_sku_diff_settings',
              click: (row) => {
                this.customerSkuDiffSettingIndex(row)
              }
            }
          ],
        }
      ]
    },
    customerSkuDiffSettingIndex(row) {
      this.$refs.mms_sku_diff_setting.showByCustomerIndex(row)
    },
    customerSkuDiffSettingDialog(rows) {
      this.$refs.mms_sku_diff_setting.showByCustomers(rows)
    },


    companyAssignWarehouse() {
      if (this.assignWarehouseFormValue.companyIdList && this.assignWarehouseFormValue.companyIdList.length > 0) {
        this.$ajax({
          url: '/ums-api/customer/CustomerCompanyRpc/assignWarehouse4Company.json',
          type: 'json',
          data: {
            companyIdList: this.assignWarehouseFormValue.companyIdList,
            warehouseIdList: this.assignWarehouseFormValue.value
          },
          success: (res) => {
            if (res && res.code === 0) {
              this.$message({
                showClose: true,
                message: '分配仓库成功',
                type: 'success'
              })
              this.assignWarehouseDialogFormVisible = false
              this.reload()
            } else {
              this.$message.error(res.message)
            }
          }
        });
      }
    },


    assignWarehousePrefix() {
      let idList = []
      let customerNoList = []
      let label = ''
      let _list = this.selection

      if (_list.length === 0) {
        return this.$message.error(this.$tt('tip_please_tick'))
      }

      for (var i = 0; i < _list.length; i++) {
        let r = _list[i]
        let str = ''
        if (r.isTest == 'Y') {
          str = '[' + r.companyCode + '] ' + r.companyName + ' (测试企业)'
        }

        if (r.companyCode && r.companyCode != '') {
          str = '[' + r.companyCode + '] ' + r.companyName + (r.customerType == 'PERSON' ? ' (个人)' : '')
        }
        str = r.companyName + (r.customerType == 'PERSON' ? ' (个人)' : '')


        label = str + (i === 0 ? '' : ', ')
        customerNoList.push(str)
        idList.push(r.id)
      }

      this.assignWarehouseFormValue.companyIdList = idList
      this.assignWarehouseFormValue.customerNoList = customerNoList
      this.assignWarehouseFormValue.customerNoLabel = label

      this.assignWarehouseDialogFormVisible = true
    },

    filterMethod(query, item) {
      return item.name.indexOf(query) > -1;
    },

    generateCompanyCode(call) {
      this.$ajax({
        url: '/ums-api/customer/CustomerCompanyRpc/generateCompanyCode.json',
        loading: {
          target: "#customerAuditDialog .el-dialog__body",
          lock: true,
          text: this.$t("label_generate_ing"),
        },
        success: (responseData) => {
          if (responseData && responseData.data) {
            if (call) call(responseData.data)
          }
        }
      });

    },
  }




};

</script>
<style></style>
